var count = 0; //判断用户是否第一次进行touchmove操作
var startX, startY;var endX, endY;var distanceX, distanceY;
function touchLoad (){
    document.addEventListener('touchstart',touch, false);
    document.addEventListener('touchmove',touch, false);
    document.addEventListener('touchend',touch, false);
    function touch (event){
        var event = event || window.event;
        switch(event.type){
            case "touchstart":
            	count = 0; //每次开始点击时清零 
            	startX = event.touches[0].clientX;
            	startY = event.touches[0].clientY;
                break;
            case "touchend":
            	endX = event.changedTouches[0].clientX;
            	endY = event.changedTouches[0].clientY;
            	distanceX = Math.abs(startX - endX);
            	distanceY = Math.abs(startY - endY);
                if (distanceX > distanceY) {
            		  //startX - endX > 0 ? swipeLeft() : swipeRight();
            	}
                break;
            case "touchmove":
                if (count === 0){
                    endX = event.touches[0].clientX;
                    endY = event.touches[0].clientY;
                    distanceX = Math.abs(startX - endX);
                    distanceY = Math.abs(startY - endY);
                    if (distanceX > distanceY) {
                    	event.preventDefault();
                    }
                }
                count++;
                break;
        }
         
    }
}
window.addEventListener('load',touchLoad, false);